Fixed testsuite
authorMarvin Löbel <loebel.marvin@gmail.com>
Wed, 28 Oct 2015 09:20:00 +0000 (10:20 +0100)
committerMarvin Löbel <loebel.marvin@gmail.com>
Wed, 28 Oct 2015 11:15:37 +0000 (12:15 +0100)
15 files changed:
tests/support/mod.rs
tests/test_cargo.rs
tests/test_cargo_bench.rs
tests/test_cargo_compile.rs
tests/test_cargo_compile_git_deps.rs
tests/test_cargo_compile_path_deps.rs
tests/test_cargo_cross_compile.rs
tests/test_cargo_install.rs
tests/test_cargo_new.rs
tests/test_cargo_package.rs
tests/test_cargo_registry.rs
tests/test_cargo_search.rs
tests/test_cargo_test.rs
tests/test_shell.rs
tests/tests.rs

index b345f245033bb51ce59f3f0546f355da4a3a5e3c..e3fbc619abda8e72a82e9073b15a06691b64d118 100644 (file)
@@ -12,8 +12,9 @@ use std::usize;
 
 use url::Url;
 use hamcrest as ham;
-use cargo::util::{process,ProcessBuilder};
+use cargo::util::ProcessBuilder;
 use cargo::util::ProcessError;
+use cargo::util::process;
 
 use support::paths::CargoPathExt;
 
@@ -134,7 +135,7 @@ impl ProjectBuilder {
     }
 
     pub fn process<T: AsRef<OsStr>>(&self, program: T) -> ProcessBuilder {
-        let mut p = process(program).unwrap();
+        let mut p = process(program);
         p.cwd(&self.root())
          .env("HOME", &paths::home())
          .env_remove("CARGO_HOME")  // make sure we don't pick up an outer one
@@ -550,6 +551,10 @@ pub fn path2url(p: PathBuf) -> Url {
     Url::from_file_path(&*p).ok().unwrap()
 }
 
+pub fn cwd() -> PathBuf {
+    env::current_dir().unwrap()
+}
+
 pub static RUNNING:     &'static str = "     Running";
 pub static COMPILING:   &'static str = "   Compiling";
 pub static DOCUMENTING: &'static str = " Documenting";
index 04f55c6f29ed7f2e9f1df5737722f201cbc413c0..f2449c04a745b33532bbb7d796c64d11216fd17c 100644 (file)
@@ -43,7 +43,7 @@ fn path() -> Vec<PathBuf> {
 test!(list_commands_looks_at_path {
     let proj = project("list-non-overlapping");
     let proj = fake_executable(proj, &Path::new("path-test"), "cargo-1");
-    let mut pr = process(&cargo_dir().join("cargo")).unwrap();
+    let mut pr = process(&cargo_dir().join("cargo"));
     pr.cwd(&proj.root())
       .env("HOME", &paths::home());
 
@@ -58,7 +58,7 @@ test!(list_commands_looks_at_path {
 });
 
 test!(find_closest_biuld_to_build {
-    let mut pr = process(&cargo_dir().join("cargo")).unwrap();
+    let mut pr = process(&cargo_dir().join("cargo"));
     pr.arg("biuld").cwd(&paths::root()).env("HOME", &paths::home());
 
     assert_that(pr,
@@ -72,7 +72,7 @@ Did you mean `build`?
 
 // if a subcommand is more than 3 edit distance away, we don't make a suggestion
 test!(find_closest_dont_correct_nonsense {
-    let mut pr = process(&cargo_dir().join("cargo")).unwrap();
+    let mut pr = process(&cargo_dir().join("cargo"));
     pr.arg("asdf").cwd(&paths::root()).env("HOME", &paths::home());
 
     assert_that(pr,
@@ -92,7 +92,7 @@ test!(override_cargo_home {
         git = false
     "#).unwrap();
 
-    assert_that(process(&cargo_dir().join("cargo")).unwrap()
+    assert_that(process(&cargo_dir().join("cargo"))
                     .arg("new").arg("foo")
                     .cwd(&paths::root())
                     .env("USER", "foo")
@@ -107,22 +107,22 @@ test!(override_cargo_home {
 });
 
 test!(cargo_help {
-    assert_that(process(&cargo_dir().join("cargo")).unwrap(),
+    assert_that(process(&cargo_dir().join("cargo")),
                 execs().with_status(0));
-    assert_that(process(&cargo_dir().join("cargo")).unwrap().arg("help"),
+    assert_that(process(&cargo_dir().join("cargo")).arg("help"),
                 execs().with_status(0));
-    assert_that(process(&cargo_dir().join("cargo")).unwrap().arg("-h"),
+    assert_that(process(&cargo_dir().join("cargo")).arg("-h"),
                 execs().with_status(0));
-    assert_that(process(&cargo_dir().join("cargo")).unwrap()
+    assert_that(process(&cargo_dir().join("cargo"))
                        .arg("help").arg("build"),
                 execs().with_status(0));
-    assert_that(process(&cargo_dir().join("cargo")).unwrap()
+    assert_that(process(&cargo_dir().join("cargo"))
                        .arg("build").arg("-h"),
                 execs().with_status(0));
-    assert_that(process(&cargo_dir().join("cargo")).unwrap()
+    assert_that(process(&cargo_dir().join("cargo"))
                        .arg("help").arg("-h"),
                 execs().with_status(0));
-    assert_that(process(&cargo_dir().join("cargo")).unwrap()
+    assert_that(process(&cargo_dir().join("cargo"))
                        .arg("help").arg("help"),
                 execs().with_status(0));
 });
index 1439172586d03869d72d20f7662263ea7fc3611d..c915635dd745a518ed2ae27673dfa14a8740c342 100644 (file)
@@ -33,7 +33,7 @@ test!(cargo_bench_simple {
     assert_that(p.cargo_process("build"), execs());
     assert_that(&p.bin("foo"), existing_file());
 
-    assert_that(process(&p.bin("foo")).unwrap(),
+    assert_that(process(&p.bin("foo")),
                 execs().with_stdout("hello\n"));
 
     assert_that(p.cargo("bench"),
@@ -177,7 +177,7 @@ test!(cargo_bench_failing_test {
     assert_that(p.cargo_process("build"), execs());
     assert_that(&p.bin("foo"), existing_file());
 
-    assert_that(process(&p.bin("foo")).unwrap(),
+    assert_that(process(&p.bin("foo")),
                 execs().with_stdout("hello\n"));
 
     assert_that(p.cargo("bench"),
index 646b50651d3d79b63e41d24a37bfaaa8e42ed163..89b50ea0eb46b74c4eb8f26b8c95afa01cb9d678 100644 (file)
@@ -21,7 +21,7 @@ test!(cargo_compile_simple {
     assert_that(p.cargo_process("build"), execs());
     assert_that(&p.bin("foo"), existing_file());
 
-    assert_that(process(&p.bin("foo")).unwrap(),
+    assert_that(process(&p.bin("foo")),
                 execs().with_stdout("i am foo\n"));
 });
 
@@ -327,7 +327,7 @@ test!(cargo_compile_with_warnings_in_a_dep_package {
     assert_that(&p.bin("foo"), existing_file());
 
     assert_that(
-      process(&p.bin("foo")).unwrap(),
+      process(&p.bin("foo")),
       execs().with_stdout("test passed\n"));
 });
 
@@ -385,7 +385,7 @@ test!(cargo_compile_with_nested_deps_inferred {
     assert_that(&p.bin("foo"), existing_file());
 
     assert_that(
-      process(&p.bin("foo")).unwrap(),
+      process(&p.bin("foo")),
       execs().with_stdout("test passed\n"));
 });
 
@@ -443,7 +443,7 @@ test!(cargo_compile_with_nested_deps_correct_bin {
     assert_that(&p.bin("foo"), existing_file());
 
     assert_that(
-      process(&p.bin("foo")).unwrap(),
+      process(&p.bin("foo")),
       execs().with_stdout("test passed\n"));
 });
 
@@ -510,7 +510,7 @@ test!(cargo_compile_with_nested_deps_shorthand {
     assert_that(&p.bin("foo"), existing_file());
 
     assert_that(
-      process(&p.bin("foo")).unwrap(),
+      process(&p.bin("foo")),
       execs().with_stdout("test passed\n"));
 });
 
@@ -576,7 +576,7 @@ test!(cargo_compile_with_nested_deps_longhand {
 
     assert_that(&p.bin("foo"), existing_file());
 
-    assert_that(process(&p.bin("foo")).unwrap(),
+    assert_that(process(&p.bin("foo")),
                 execs().with_stdout("test passed\n"));
 });
 
@@ -717,7 +717,7 @@ test!(crate_version_env_vars {
     assert_that(p.cargo_process("build").arg("-v"), execs().with_status(0));
 
     println!("bin");
-    assert_that(process(&p.bin("foo")).unwrap(),
+    assert_that(process(&p.bin("foo")),
                 execs().with_stdout(&format!("0-5-1 @ alpha.1 in {}\n",
                                             p.root().display())));
 
@@ -862,7 +862,7 @@ test!(ignore_broken_symlinks {
     assert_that(p.cargo_process("build"), execs());
     assert_that(&p.bin("foo"), existing_file());
 
-    assert_that(process(&p.bin("foo")).unwrap(),
+    assert_that(process(&p.bin("foo")),
                 execs().with_stdout("i am foo\n"));
 });
 
@@ -1067,9 +1067,9 @@ test!(explicit_examples {
         "#);
 
     assert_that(p.cargo_process("test").arg("-v"), execs().with_status(0));
-    assert_that(process(&p.bin("examples/hello")).unwrap(),
+    assert_that(process(&p.bin("examples/hello")),
                         execs().with_stdout("Hello, World!\n"));
-    assert_that(process(&p.bin("examples/goodbye")).unwrap(),
+    assert_that(process(&p.bin("examples/goodbye")),
                         execs().with_stdout("Goodbye, World!\n"));
 });
 
@@ -1100,9 +1100,9 @@ test!(implicit_examples {
         "#);
 
     assert_that(p.cargo_process("test"), execs().with_status(0));
-    assert_that(process(&p.bin("examples/hello")).unwrap(),
+    assert_that(process(&p.bin("examples/hello")),
                 execs().with_stdout("Hello, World!\n"));
-    assert_that(process(&p.bin("examples/goodbye")).unwrap(),
+    assert_that(process(&p.bin("examples/goodbye")),
                 execs().with_stdout("Goodbye, World!\n"));
 });
 
@@ -1120,7 +1120,7 @@ test!(standard_build_no_ndebug {
         "#);
 
     assert_that(p.cargo_process("build"), execs().with_status(0));
-    assert_that(process(&p.bin("foo")).unwrap(),
+    assert_that(process(&p.bin("foo")),
                 execs().with_stdout("slow\n"));
 });
 
@@ -1139,7 +1139,7 @@ test!(release_build_ndebug {
 
     assert_that(p.cargo_process("build").arg("--release"),
                 execs().with_status(0));
-    assert_that(process(&p.release_bin("foo")).unwrap(),
+    assert_that(process(&p.release_bin("foo")),
                 execs().with_stdout("fast\n"));
 });
 
@@ -1156,7 +1156,7 @@ test!(inferred_main_bin {
         "#);
 
     assert_that(p.cargo_process("build"), execs().with_status(0));
-    assert_that(process(&p.bin("foo")).unwrap(), execs().with_status(0));
+    assert_that(process(&p.bin("foo")), execs().with_status(0));
 });
 
 test!(deletion_causes_failure {
@@ -1206,7 +1206,7 @@ test!(bad_cargo_toml_in_target_dir {
         .file("target/Cargo.toml", "bad-toml");
 
     assert_that(p.cargo_process("build"), execs().with_status(0));
-    assert_that(process(&p.bin("foo")).unwrap(), execs().with_status(0));
+    assert_that(process(&p.bin("foo")), execs().with_status(0));
 });
 
 test!(lib_with_standard_name {
@@ -1597,7 +1597,7 @@ test!(cargo_platform_specific_dependency_wrong_platform {
     p.cargo_process("build").exec_with_output().unwrap();
 
     assert_that(&p.bin("foo"), existing_file());
-    assert_that(process(&p.bin("foo")).unwrap(),
+    assert_that(process(&p.bin("foo")),
                 execs());
 
     let loc = p.root().join("Cargo.lock");
@@ -1986,7 +1986,7 @@ test!(build_multiple_packages {
                 execs());
 
     assert_that(&p.bin("foo"), existing_file());
-    assert_that(process(&p.bin("foo")).unwrap(),
+    assert_that(process(&p.bin("foo")),
                 execs().with_stdout("i am foo\n"));
 
     let d1_path = &p.build_dir().join("debug").join("deps")
@@ -1995,10 +1995,10 @@ test!(build_multiple_packages {
                                 .join(format!("d2{}", env::consts::EXE_SUFFIX));
 
     assert_that(d1_path, existing_file());
-    assert_that(process(d1_path).unwrap(), execs().with_stdout("d1"));
+    assert_that(process(d1_path), execs().with_stdout("d1"));
 
     assert_that(d2_path, existing_file());
-    assert_that(process(d2_path).unwrap(),
+    assert_that(process(d2_path),
                 execs().with_stdout("d2"));
 });
 
index fcab5d846a33162811b60e9858c1971bb56e6bef..c9b2d93c39732ef3acd4eb745c6068fd9a613a73 100644 (file)
@@ -8,7 +8,6 @@ use support::{git, project, execs, main_file, path2url};
 use support::{COMPILING, UPDATING, RUNNING};
 use support::paths::{self, CargoPathExt};
 use hamcrest::{assert_that,existing_file};
-use cargo;
 use cargo::util::process;
 
 fn setup() {
@@ -70,7 +69,7 @@ test!(cargo_compile_simple_git_dep {
     assert_that(&project.bin("foo"), existing_file());
 
     assert_that(
-      cargo::util::process(&project.bin("foo")).unwrap(),
+      process(&project.bin("foo")),
       execs().with_stdout("hello world\n"));
 });
 
@@ -137,7 +136,7 @@ test!(cargo_compile_git_dep_branch {
     assert_that(&project.bin("foo"), existing_file());
 
     assert_that(
-      cargo::util::process(&project.bin("foo")).unwrap(),
+      process(&project.bin("foo")),
       execs().with_stdout("hello world\n"));
 });
 
@@ -205,7 +204,7 @@ test!(cargo_compile_git_dep_tag {
 
     assert_that(&project.bin("foo"), existing_file());
 
-    assert_that(cargo::util::process(&project.bin("foo")).unwrap(),
+    assert_that(process(&project.bin("foo")),
                 execs().with_stdout("hello world\n"));
 
     assert_that(project.cargo("build"),
@@ -282,7 +281,7 @@ test!(cargo_compile_with_nested_paths {
 
     assert_that(&p.bin("parent"), existing_file());
 
-    assert_that(cargo::util::process(&p.bin("parent")).unwrap(),
+    assert_that(process(&p.bin("parent")),
                 execs().with_stdout("hello world\n"));
 });
 
@@ -354,7 +353,7 @@ test!(cargo_compile_with_meta_package {
 
     assert_that(&p.bin("parent"), existing_file());
 
-    assert_that(cargo::util::process(&p.bin("parent")).unwrap(),
+    assert_that(process(&p.bin("parent")),
                 execs().with_stdout("this is dep1 this is dep2\n"));
 });
 
@@ -1220,7 +1219,7 @@ test!(git_dep_build_cmd {
     assert_that(p.cargo("build"),
                 execs().with_status(0));
 
-    assert_that(cargo::util::process(&p.bin("foo")).unwrap(),
+    assert_that(process(&p.bin("foo")),
                 execs().with_stdout("0\n"));
 
     // Touching bar.rs.in should cause the `build` command to run again.
@@ -1230,7 +1229,7 @@ test!(git_dep_build_cmd {
     assert_that(p.cargo("build"),
                 execs().with_status(0));
 
-    assert_that(cargo::util::process(&p.bin("foo")).unwrap(),
+    assert_that(process(&p.bin("foo")),
                 execs().with_stdout("1\n"));
 });
 
index b8b89fe6515cdbfcd9ba22f9658c45fa9bf53688..319ec6e0c447ba627033b4eda80c321bfea72b54 100644 (file)
@@ -6,8 +6,7 @@ use support::{project, execs, main_file};
 use support::{COMPILING, RUNNING};
 use support::paths::{self, CargoPathExt};
 use hamcrest::{assert_that, existing_file};
-use cargo;
-use cargo::util::{process};
+use cargo::util::process;
 
 fn setup() {
 }
@@ -83,7 +82,7 @@ test!(cargo_compile_with_nested_deps_shorthand {
 
     assert_that(&p.bin("foo"), existing_file());
 
-    assert_that(cargo::util::process(&p.bin("foo")).unwrap(),
+    assert_that(process(&p.bin("foo")),
                 execs().with_stdout("test passed\n").with_status(0));
 
     println!("cleaning");
@@ -238,7 +237,7 @@ test!(cargo_compile_with_transitive_dev_deps {
 
     assert_that(&p.bin("foo"), existing_file());
 
-    assert_that(cargo::util::process(&p.bin("foo")).unwrap(),
+    assert_that(process(&p.bin("foo")),
                 execs().with_stdout("zoidberg\n"));
 });
 
@@ -687,7 +686,7 @@ test!(path_dep_build_cmd {
 
     assert_that(&p.bin("foo"), existing_file());
 
-    assert_that(cargo::util::process(&p.bin("foo")).unwrap(),
+    assert_that(process(&p.bin("foo")),
                 execs().with_stdout("0\n"));
 
     // Touching bar.rs.in should cause the `build` command to run again.
@@ -702,7 +701,7 @@ test!(path_dep_build_cmd {
                                     COMPILING, p.url(),
                                     COMPILING, p.url())));
 
-    assert_that(cargo::util::process(&p.bin("foo")).unwrap(),
+    assert_that(process(&p.bin("foo")),
                 execs().with_stdout("1\n"));
 });
 
index 1aae08f3cca1dd4787584ca2f9f60f40dfad66d4..3d4174afb435ee9179ffa302170f75f129017584 100644 (file)
@@ -74,7 +74,7 @@ test!(simple_cross {
                 execs().with_status(0));
     assert_that(&p.target_bin(&target, "foo"), existing_file());
 
-    assert_that(process(&p.target_bin(&target, "foo")).unwrap(),
+    assert_that(process(&p.target_bin(&target, "foo")),
                 execs().with_status(0));
 });
 
@@ -110,7 +110,7 @@ test!(simple_deps {
                 execs().with_status(0));
     assert_that(&p.target_bin(&target, "foo"), existing_file());
 
-    assert_that(process(&p.target_bin(&target, "foo")).unwrap(),
+    assert_that(process(&p.target_bin(&target, "foo")),
                 execs().with_status(0));
 });
 
@@ -187,7 +187,7 @@ test!(plugin_deps {
                 execs().with_status(0));
     assert_that(&foo.target_bin(&target, "foo"), existing_file());
 
-    assert_that(process(&foo.target_bin(&target, "foo")).unwrap(),
+    assert_that(process(&foo.target_bin(&target, "foo")),
                 execs().with_status(0));
 });
 
@@ -272,7 +272,7 @@ test!(plugin_to_the_max {
                 execs().with_status(0));
     assert_that(&foo.target_bin(&target, "foo"), existing_file());
 
-    assert_that(process(&foo.target_bin(&target, "foo")).unwrap(),
+    assert_that(process(&foo.target_bin(&target, "foo")),
                 execs().with_status(0));
 });
 
index c2835792ce7825cfb2f6b73335372a72e67fe89d..1729ceb460cc7d1548e2105f53faefc2f77601b6 100644 (file)
@@ -19,7 +19,7 @@ fn setup() {
 }
 
 fn cargo_process(s: &str) -> ProcessBuilder {
-    let mut p = process(&cargo_dir().join("cargo")).unwrap();
+    let mut p = process(&cargo_dir().join("cargo"));
     p.arg(s).cwd(&paths::root())
      .env("HOME", &paths::home())
      .env_remove("CARGO_HOME");
index 398e07bec3f633bd4c38fee0c5b49babd643ae8e..0745ebfff7b2ff36c528fb7d288a962e59f048d2 100644 (file)
@@ -13,13 +13,13 @@ fn setup() {
 }
 
 fn my_process(s: &str) -> ProcessBuilder {
-    let mut p = process(s).unwrap();
+    let mut p = process(s);
     p.cwd(&paths::root()).env("HOME", &paths::home());
     return p;
 }
 
 fn cargo_process(s: &str) -> ProcessBuilder {
-    let mut p = process(&cargo_dir().join("cargo")).unwrap();
+    let mut p = process(&cargo_dir().join("cargo"));
     p.arg(s).cwd(&paths::root()).env("HOME", &paths::home());
     return p;
 }
index 6e59a364773b0089ca523b3ebc59e5d120ef9885..eff3bc76c911840105544e185fe49bb647838b8b 100644 (file)
@@ -217,7 +217,7 @@ test!(package_verbose {
         "#)
         .file("a/src/lib.rs", "");
     p.build();
-    let mut cargo = process(&cargo_dir().join("cargo")).unwrap();
+    let mut cargo = process(&cargo_dir().join("cargo"));
     cargo.cwd(&root).env("HOME", &paths::home());
     assert_that(cargo.clone().arg("build"), execs().with_status(0));
     assert_that(cargo.arg("package").arg("-v").arg("--no-verify"),
index 8209b5bb2935266adcadba2368953ea9e683fcb7..3665188d672a26d83cc01cf9304c6421706d842b 100644 (file)
@@ -557,7 +557,7 @@ test!(dev_dependency_not_used {
 test!(login_with_no_cargo_dir {
     let home = paths::home().join("new-home");
     fs::create_dir(&home).unwrap();
-    assert_that(process(&cargo_dir().join("cargo")).unwrap()
+    assert_that(process(&cargo_dir().join("cargo"))
                        .arg("login").arg("foo").arg("-v")
                        .cwd(&paths::root())
                        .env("HOME", &home),
index 6e55047f1d339cea92f91d003b2ca16647186487..2e269919bc45c44ea72134bc38368eca0480d313 100644 (file)
@@ -35,7 +35,7 @@ fn setup() {
 }
 
 fn cargo_process(s: &str) -> ProcessBuilder {
-    let mut b = process(&cargo_dir().join("cargo")).unwrap();
+    let mut b = process(&cargo_dir().join("cargo"));
     b.arg(s).cwd(&paths::root()).env("HOME", &paths::home());
     b
 }
index f5ebe9dcc63852687e8673133153c8b25dcc312a..2c423cc320ef08637bed18611b83bd241f7eb1ab 100644 (file)
@@ -31,7 +31,7 @@ test!(cargo_test_simple {
     assert_that(p.cargo_process("build"), execs());
     assert_that(&p.bin("foo"), existing_file());
 
-    assert_that(process(&p.bin("foo")).unwrap(),
+    assert_that(process(&p.bin("foo")),
                 execs().with_stdout("hello\n"));
 
     assert_that(p.cargo("test"),
@@ -188,7 +188,7 @@ test!(cargo_test_failing_test {
     assert_that(p.cargo_process("build"), execs());
     assert_that(&p.bin("foo"), existing_file());
 
-    assert_that(process(&p.bin("foo")).unwrap(),
+    assert_that(process(&p.bin("foo")),
                 execs().with_stdout("hello\n"));
 
     assert_that(p.cargo("test"),
index a2a5e56388bd30fc67ea5950a2bcd56187ed5e6e..366215be4ee5bebec8922c7398d9c57b74f63766 100644 (file)
@@ -81,7 +81,7 @@ test!(color_explicitly_enabled {
 
 test!(no_term {
     // Verify that shell creation is successful when $TERM does not exist.
-    assert_that(process(&cargo_dir().join("cargo")).unwrap()
+    assert_that(process(&cargo_dir().join("cargo"))
                     .env_remove("TERM"),
                 execs().with_stderr(""));
 });
index 612d11e0344b886374322d6e20373d1077205bfc..7fe2e27d3e6db1331bf8776ac33b333561317498 100644 (file)
@@ -64,7 +64,7 @@ mod test_cargo_verify_project;
 mod test_cargo_version;
 mod test_shell;
 
-thread_local!(static RUSTC: Rustc = Rustc::new("rustc").unwrap());
+thread_local!(static RUSTC: Rustc = Rustc::new("rustc", &support::cwd()).unwrap());
 
 fn rustc_host() -> String {
     RUSTC.with(|r| r.host.clone())